/**  
 * @author Ivam Henrique Marques dos Santos
 *         email: ivam.santos@skytef.com.br
 *         skype: ivam.santos.skytef
 *         telefone: +55 11 96214-7543
 */
package br.skytef.stmanager.utils;

import java.sql.Connection;  
import javax.sql.DataSource;  
import javax.naming.Context;  
import javax.naming.InitialContext;   
/**  
 *Class Util para conexão com a base de dados via context (Servidor Tomcat)
 */
public class Pool {      
	/**
	 * Construtor
	 */
	public Pool() {  
	}  
	/**
	 * Obter conexão
	 * @return conexão
	 */
	public static Connection getConnection() {  
		Connection conn = null;  
		try {
			Context initContext = new InitialContext();
			Context envContext  = (Context)initContext.lookup("java:/comp/env");
			DataSource ds = (DataSource)envContext.lookup("jdbc/skytefdb");
			conn = ds.getConnection();      
		} catch (Exception e) {  
			e.printStackTrace(System.err);  
		}   
		return conn;  
	}  
}
